﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PocketEngine.Engine;
using PocketEngine.Images;
namespace PocketEngine.Gui
{
    public class pButton : pWidget
    {
        public string Text
        {
            get
            {
                return mText;
            }
            set
            {
                mText = value;
            }
        }
        private string mText = string.Empty;

        public pColor TopColor
        {
            get
            {
                return mTop;
            }
            set
            {
                mTop = value;
            }
        }
        private pColor mTop = new pColor(0.95f, 0.94f, 0.9f, 0.9f);
        public pColor BotColor
        {
            get
            {
                return mBot;
            }
            set
            {
                mBot = value;
            }
        }
        private pColor mBot = new pColor(0.75f, 0.75f, 0.76f, 0.75f);


        
    
        
        public pButton(int x, int y, int w, int h, string text, pWidget parent)
        {
            Set(x, y, w, h, parent);
            Text = text;
        }
        public override void OnMouseEnter()
        {
            mOver = true;
        }
        public override void OnMouseLeave()
        {
            mOver = false;    
        }
        public override void OnMouseDown(int button)
        {
            if (button == 0)
            {
                mPressed = true;
            }
        }
        public override void OnMouseUp(int button)
        {
            if (button == 0)
            {
                mPressed = false;
            }
        }
        public bool Pressed
        {
            get
            {
                return mPressed;
            }
        }
        internal bool mPressed = false;
        public bool Over
        {
            get
            {
                return mOver;
            }
        }
       
        public pColor acol = new pColor(0, 0, 0, 0);
        internal bool mOver = false;
        public override void Draw(int dx, int dy)
        {
            pColor ac = TopColor;
            if (mPressed)
            {
                ac = new pColor(1, 1, 0, 1);
            }else if (mOver)
            {
                ac = new pColor(0, 1, 1, 1);
            }
            acol = acol.Blend(ac, 0.15f);

            _Frame(dx, dy, Width, Height, acol, BotColor);
            pGuiManager.SystemFont.print(dx + 2, pEngine.Screen.Info.Height-(dy+Height) , Text);
        }
    }
}
